﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System .Data ;
using System .Data .SqlClient ;
using dhDataAcess.orderLinqDAL ;

namespace dhDataAcess.orderDAL
{
  public   class pbomMarkDAL
    {

        string tableName = "phomMark";
        private SqlTransaction tran = null;
        private SqlConnection conn = null;
        public pbomMarkDAL(SqlTransaction _transaction, SqlConnection _conn)
        {
            tran = _transaction ;
            conn = _conn;
        }
        /// <summary>
        /// 插入产品BOM技术参数表数据
        /// </summary>
        /// <param name="deptRow"></param>
        /// <returns></returns>
        public int pbomMarkInsert(pbomMarkModel row)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
          //  string insertstr = baseBLL.dTableColumnRead.insertSqlStr(tableName).ToString();
            string insertstr = "insert into pbomMark (mark,zzmachineqty,zzdifficulty,zzyujiproduction,zzspeed,zzproduction,zzbasicspec,zzzwDensity,zzproduceqty,zzrequest,numberNf,numberKf,methods,speedNf,speedKf,productionNf,productionKf,endwidth,endshrink,endopen,startwidth,startshrink,startopen,twoLength,zwDensity,difficulty,gqDensity,request,pname,zzzwjgtx) values(@mark,@zzmachineqty,@zzdifficulty,@zzyujiproduction,@zzspeed,@zzproduction,@zzbasicspec,@zzzwDensity,@zzproduceqty,@zzrequest,@numberNf,@numberKf,@methods,@speedNf,@speedKf,@productionNf,@productionKf,@endwidth,@endshrink,@endopen,@startwidth,@startshrink,@startopen,@twoLength,@zwDensity,@difficulty,@gqDensity,@request,@pname,@zzzwjgtx)";
            SqlParameter[] para = {
                                        new SqlParameter ("@mark",row .mark ),
                                        new SqlParameter ("@numberNf",row .numberNf ),
                                        new SqlParameter ("@numberKf",row .numberKf ),
                                        new SqlParameter ("@methods",row .methods ),
                                        new SqlParameter ("@speedNf",row .speedNf ),
                                        new SqlParameter ("@speedKf",row .speedKf ),
                                        new SqlParameter ("@productionNf",row .productionNf ),
                                        new SqlParameter ("@productionKf",row .productionKf ),
                                        new SqlParameter ("@endwidth",row .endwidth ),
                                        new SqlParameter ("@endshrink",row .endshrink ),
                                        new SqlParameter ("@endopen",row .endopen ),
                                        new SqlParameter ("@startwidth",row.startwidth  ),
                                        new SqlParameter ("@startshrink",row .startshrink ),
                                        new SqlParameter ("@startopen",row .startopen ),
                                        new SqlParameter ("@twoLength",row .twoLength ),
                                        new SqlParameter ("@zwDensity",row .zwDensity ),
                                        new SqlParameter ("@difficulty",row .difficulty ),
                                        new SqlParameter ("@gqDensity",row .gqDensity ),
                                        new SqlParameter ("@request",row .request ),
                                        new SqlParameter ("@pname",row .pname ),
                                        new SqlParameter ("@zzrequest",row .zzrequest),
                                        new SqlParameter ("@zzdifficulty",row .zzdifficulty ),
                                        new SqlParameter ("@zzproduceqty",row.zzproduceqty  ),
                                        new SqlParameter ("@zzzwDensity",row .zzzwDensity ),
                                        new SqlParameter ("@zzbasicspec",row .zzbasicspec ),
                                        new SqlParameter ("@zzproduction",row .zzproduction ),
                                        new SqlParameter ("@zzspeed",row .zzspeed ),
                                        new SqlParameter ("@zzyujiproduction",row .zzyujiproduction ),
                                        new SqlParameter ("@zzmachineqty",row .zzmachineqty ),
                                        new SqlParameter ("@zzzwjgtx",row .zzzwjgtx  )
                                    };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = insertstr;
            cmd.Transaction = tran;
            int i = cmd.ExecuteNonQuery();
            return i;
        }
        /// <summary>
        /// 更新产品BOM技术参数表数据
        /// </summary>
        /// <param name="deptRow"></param>
        /// <returns></returns>
        public int pbomMarkUpdate(pbomMarkModel row)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
           // string updatestr = baseBLL.dTableColumnRead.updateSqlStr(tableName).ToString();
            string updatestr = "update pbomMark set mark=@mark,zzmachineqty=@zzmachineqty,zzdifficulty=@zzdifficulty,zzyujiproduction=@zzyujiproduction,zzspeed=@zzspeed,zzproduction=@zzproduction,zzbasicspec=@zzbasicspec,zzzwDensity=@zzzwDensity,zzproduceqty=@zzproduceqty,zzrequest=@zzrequest,numberNf=@numberNf,numberKf=@numberKf,methods=@methods,speedNf=@speedNf,speedKf=@speedKf,productionNf=@productionNf,productionKf=@productionKf,endwidth=@endwidth,endshrink=@endshrink,endopen=@endopen,startwidth=@startwidth,startshrink=@startshrink,startopen=@startopen,twoLength=@twoLength,zwDensity=@zwDensity,difficulty=@difficulty,gqDensity=@gqDensity,request=@request,pname=@pname,zzzwjgtx=@zzzwjgtx where pname=@pname";
            SqlParameter[] para = {
                                        new SqlParameter ("@mark",row .mark ),
                                        new SqlParameter ("@numberNf",row .numberNf ),
                                        new SqlParameter ("@numberKf",row .numberKf ),
                                        new SqlParameter ("@methods",row .methods ),
                                        new SqlParameter ("@speedNf",row .speedNf ),
                                        new SqlParameter ("@speedKf",row .speedKf ),
                                        new SqlParameter ("@productionNf",row .productionNf ),
                                        new SqlParameter ("@productionKf",row .productionKf ),
                                        new SqlParameter ("@endwidth",row .endwidth ),
                                        new SqlParameter ("@endshrink",row .endshrink ),
                                        new SqlParameter ("@endopen",row .endopen ),
                                        new SqlParameter ("@startwidth",row .startwidth  ),
                                        new SqlParameter ("@startshrink",row .startshrink ),
                                        new SqlParameter ("@startopen",row .startopen ),
                                        new SqlParameter ("@twoLength",row .twoLength ),
                                        new SqlParameter ("@zwDensity",row .zwDensity ),
                                        new SqlParameter ("@difficulty",row .difficulty ),
                                        new SqlParameter ("@gqDensity",row .gqDensity ),
                                        new SqlParameter ("@request",row .request ),
                                        new SqlParameter ("@pname",row .pname ) ,
                                        new SqlParameter ("@zzrequest",row .zzrequest),
                                        new SqlParameter ("@zzdifficulty",row .zzdifficulty ),
                                        new SqlParameter ("@zzproduceqty",row.zzproduceqty  ),
                                        new SqlParameter ("@zzzwDensity",row .zzzwDensity ),
                                        new SqlParameter ("@zzbasicspec",row .zzbasicspec ),
                                        new SqlParameter ("@zzproduction",row .zzproduction ),
                                        new SqlParameter ("@zzspeed",row .zzspeed ),
                                        new SqlParameter ("@zzyujiproduction",row .zzyujiproduction ),
                                        new SqlParameter ("@zzmachineqty",row .zzmachineqty ),
                                        new SqlParameter ("@zzzwjgtx",row .zzzwjgtx  )
                                    };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = updatestr;
            cmd.Transaction = tran;
            int i = cmd.ExecuteNonQuery();
            return i;
        }
        /// <summary>
        /// 删除一行产品BOM技术参数表数据
        /// </summary>
        /// <param name="deptRow"></param>
        /// <returns></returns>
        public int pbomMarkDel(string recordid)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
            string deletestr = baseBLL.dTableColumnRead.delSqlStr (tableName).ToString();
            SqlParameter[] para = {
                                  
                                    new SqlParameter ("@recordid",recordid ),
                                  
                                  };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = deletestr ;
            cmd.Transaction = tran;
            int i = cmd.ExecuteNonQuery();
            return i;
        }
    }
}
